<template>
	<view class="body">
		<view class="my_body">
			<view class="my_top">
				<view class="my_top_top">
					<view class="my_top_top_left" >
						<view class="my_tx_left">
							<image :src="my_tx" class="my_tx"></image>
						</view>
						<view class="my_top_top_name" v-if="is_login" @click="go('/pages/index/change_user')">
							<view class="hei_38_bold my_top_she" >{{user.username}}</view>
							<view class="change hei_26_bold PingFang">
								修改个人信息
							</view>
						</view>
						<view class="hei_38_bold PingFang zhudeng" v-if="!is_login">
							<text  @click="go('/pages/index/login')">登录</text>/<text  @click="go('/pages/index/register')">注册</text>
						</view>
						<navigator url="/pages/index/change_user" class="shezhi hei_26" v-if="is_login">
						 <image src="/static/img/hei_shezhi.png" mode=""></image>设置
						</navigator>
					</view>
				</view>
				<view class="my_shujv hui_24_bold PingFang">
					<view class="my_shujv_item"  @click="go('/pages/index/jifen_list')">
						<view class="my_shujv_item_top hei_30_bold">
							{{user?user.totalPoints:0}}
						</view>
						<text class="">积分</text>
					</view>
					<view class="my_shujv_item" @click="go('/pages/index/jifen_list')">
						<view class="my_shujv_item_top hei_30_bold">
							{{user?user.usedPoints:0}}
						</view>
						<text class="">已用</text>
					</view>
					
					<view class="my_shujv_item" @click="go('/pages/index/jifen_list')">
						<view class="my_shujv_item_top hei_30_bold">
							{{user?user.points:0}}
						</view>
						<text class="">剩余</text>
					</view>

				</view>
					
			</view>


			<view class="my_bottom">
				<view class="my_list my_fuwu">
					<view class="my_list_top_body">
						<view class="my_list_top" >
							<view class="hei_30_bold">我的积分</view>
							
						</view>
					</view>
					<view class="my_list_bottom hei_24 my_zhanghao_bottom " :class="button_color==2?'hong_item':''">
					    <view class="my_item" @click="go('/pages/index/jifen_list')">
					    	<image src="/static/img/mingxi.png" style="width: 50rpx;height: 50rpx;"></image>
					    	<view>积分明细</view>
					    </view>
						<view class="my_item" @click="go('/pages/index/duihuan_list?state=9')">
							<image src="/static/img/huan_jilu.png" style="width: 50rpx;height: 50rpx;"></image>
							<view>兑换记录</view>
							
						</view>
				
					</view>
				</view>
                <view class="my_list my_fuwu">
                	<view class="my_list_top_body">
                		<view class="my_list_top"  @click="go('/pages/index/dingdan')">
                			<view class="hei_30_bold">我的订单</view>
							<image src="/static/img/go_right.png" mode=""></image>
                		</view>
                	</view>
                	<view class="my_list_bottom hei_24 my_zhanghao_bottom " :class="button_color==2?'hong_item':''">
                	    <view class="my_item" @click="go('/pages/index/dingdan')">
                	    	<image src="/static/img/my_dd1_hong.png" style="width: 50rpx;height: 44rpx;"></image>
                	    	<view>全部订单</view>
                	    </view>
						<view class="my_item" @click="go('/pages/index/dingdan?state=0')">
							<image src="/static/img/my_dd3_hong.png" style="width: 44rpx;height: 44rpx;"></image>
							<view>审核中</view>
							
						</view>
						<view class="my_item" @click="go('/pages/index/dingdan?state=1')">
							<image src="/static/img/my_dd6_hong.png" style="width: 40rpx;height: 44rpx;"></image>
							<view>进行中</view>
							
						</view>
						<view class="my_item" @click="go('/pages/index/dingdan?state=2')">
							<image src="/static/img/my_dd8_hong.png" style="width: 44rpx;height: 44rpx;"></image>
							<view>已完成</view>
							
						</view>
						<view class="my_item" @click="go('/pages/index/dingdan?state=3')">
							<image src="/static/img/my_dd11_hong.png" style="width: 52rpx;height: 44rpx;"></image>
							<view>已取消</view>
							
						</view>
						<view class="my_item" @click="go('/pages/index/dingdan?state=4')">
							<image src="/static/img/my_dd11_hong.png" style="width: 52rpx;height: 44rpx;"></image>
							<view>审核失败</view>
							
						</view>
                
                	</view>
                </view>
				
				
	
				
       
				
				<view class="my_list my_fuwu">
					<view class="my_list_top_body">
						<view class="my_list_top">
							<view class="hei_30_bold">账号管理</view>
						</view>
					</view>
					<view class="my_list_bottom hei_24 my_zhanghao_bottom ">

						
						<view class="my_item" @click="go('/pages/index/change_user',1)">
							<image src="/static/img/zhanghao1_hong.png"></image>
							<view>个人资料</view>
						</view>
						<view class="my_item" @click="go('/pages/index/gonggao',1)">
							<image src="/static/img/zhanghao3_hong.png"></image>
							<view>网站公告</view>
						</view>
						<view class="my_item" @click="go('/pages/index/kefu',1)">
							<image src="/static/img/zhanghao4_hong.png"></image>
							<view>在线客服</view>
						</view>


					</view>
				</view>
			</view>
		</view>
		<!-- <view class="padding_bottom"></view> -->
		<!-- <tabBar :currentPage="currentPage" ></tabBar> -->
<uni-popup id="tan_login" ref="tan_login" type="center">
<view class="tan_login">
	<view class="tan_login_box">
		<view class="tan_login_logo">
			<image :src="logo" mode=""></image>
		</view>
		<view class="hei_38_bold PingFang tan_login_shouquan">
			登录授权
		</view>
		<view class="tan_login_tishi hei_28">
			等你好久啦~
		</view>
		<view class="tan_login_bottom">
			<button type="button"  class="bai_30 "    open-type="getPhoneNumber" lang="zh_CN" @getphonenumber="bindGetPhoneNumber" scope='phoneNumber'>立即授权</button>
		</view>	
		<view class="tan_login_mima hei_24" @click="go('/pages/index/login',1)">
			账号密码登录
		</view>
	</view>
	<view class="tan_login_close">
		<image src="/static/img/login_close.png" mode=""@click="$refs.tan_login.close()"></image>
	</view>
</view>
</uni-popup>


	</view>
</template>

<script>
	// import tabBar from '@/components/tabbar/tabbar.vue';
export default {
	data() {
		return {
			img_url: uni.getStorageSync('img_url'),
			currentPage: '/pages/index/my',
			user: '',
			is_login:false,
			my_tx:'/static/img/tx_moren.png',
			logo:''
		};
	},
	// components: {
	// 	tabBar
	// },
	onShow() {
		if(uni.getStorageSync("Cookie")){
			this.get_user()
		}else{
			this.is_login=false
		}
            
	},
	onReady() {
	  
	},
	onLoad(option) {
          this.get_peizhi()
	
	},
	//下拉刷新
	onPullDownRefresh: function() {
		this.get_api();
	},
	methods: {
		go(url,type) {
			var that=this
			// if(type&&type==1){
			// 	uni.navigateTo({
			// 		url: url
			// 	});
			// 	return false
			// }
			// if(!this.is_login){
			// 	// #ifdef MP-WEIXIN
			// 		 this.$refs.tan_login.open()
			// 	//#endif
			// 	// #ifdef H5||APP-PLUS
			// 	   if(url=='/pages/index/register'){
			// 		   uni.redirectTo({
			// 		   		url:url
			// 		   })
			// 	   }else{
			// 		   uni.redirectTo({
			// 		   		url:'/pages/index/login'
			// 		   })
			// 	   }
				   
			// 	//#endif
			// 	return false
			// }
			uni.navigateTo({
				url: url
			});
		},
		get_peizhi(){
		
			this.$http
				.get({
					url: '/api/getConfig',
				})
				.then(res => {
					if (res.code == 200&&res.config) {
						
						
						this.logo=res.config.website_logo
					}
				});
		},
		fangda(){
			this.$refs.tan_fangfa.open();
		},
		// 保存图片
			save(url){
				let that = this;
				// #ifdef H5
				
				let alink = document.createElement('a');
				alink.href = url;
				alink.download = url;
				alink.click();
				// #endif
				// #ifdef APP-PLUS||MP-ALIPAY||MP-WEIXIN||MP-KUAISHOU
				// #ifdef APP-PLUS
				if (uni.getSystemInfoSync().platform == 'android'){
					that.$refs.popup_quanxian.open();
				}
				//#endif
				
				uni.showLoading({
					title: '保存中'
				});
				uni.saveImageToPhotosAlbum({
					filePath: url+'',
					success: function() {
						uni.hideLoading();
						uni.showToast({
							title: '保存成功',
							icon: 'none'
						});
						that.$refs.popup_quanxian.close();
						uni.setStorageSync('is_tanxiangji', 1);
					},
					fail: function() {
						uni.hideLoading();
						uni.showToast({
							title: '保存失败，请稍后重试',
							icon: 'none'
						});
						that.$refs.popup_quanxian.close();
					}
				});
				// #endif
			},
		
		bindGetPhoneNumber(e){
			console.log(e)
			return false
			   if(e.detail.errorMessage){
				   uni.showToast({
					title: e.detail.errorMessage,
					icon: 'none'
				   });
				   uni.redirectTo({
					url:'/pages/index/login'
				   })
			   }else{

				   //#ifdef MP-WEIXIN
				   this.$http
					.post({
						url: '/wechatLogin',
						data: {
							code:e.detail.code,
							source1:'xcx',
							source:'user'
							
						}
					})
					.then(res => {
						if (res.code == 0) {
							uni.setStorageSync("Cookie",res.data.cookie)
							uni.showToast({
								title: '登录成功'
							});
							this.islogin=true
							this.$refs.tan_login.close()
							this.get_api();
						}else{
							uni.redirectTo({
								url:'/pages/index/login'
							})
						}
				   });
				   //#endif

			   }
		},
		replace_em(str) {
			str = str.replace(/amp;/g, "");
			str = str.replace(/&nbsp;/g, "");
			str = str.replace(/nbsp;/g, "");
			str = str.replace(/\</g, '&lt;');
			// str = str.replace(/\>/g, '&gt;');
			str = str.replace(/&gt;/g, ">");
			str = str.replace(/gt;/g, ">");
			str = str.replace(/\n/g, '<br/>');
			str = str.replace(/\[em_([0-9]*)\]/g, '<img src="https://imgxh.hongvv.com/zu/static/bkhumor-emoji/$1.gif" border="0" style="width:40rpx"/></img>');
			return str;
		},
		fuzhi(text,type) {
			if(type==2){
				text=text.replace(/[^a-zA-Z0-9]/ig,"")
				uni.setClipboardData({
					data: String(text),
					success: function() {
						uni.showToast({
							title: '复制成功',
							duration: 2000
						});
					}
				});
				return false
			}
			uni.setClipboardData({
				data: String(text),
				success: function() {
					uni.showToast({
						title: '复制成功',
						duration: 2000
					});
				}
			});
		},
		get_user() {
			this.$http
				.get({
					url: '/api/getUserInfo',
					data:{
						none_load:true,
					}
				})
				.then(res => {
					if (res.code == 200) {
						if (res.user) {
							this.is_login=true
							this.user = res.user;
							this.my_tx=res.user.avatar_url
							
						} else {
							this.is_login=false
						}
					}
				});
		},

	}
};
</script>

<style>
page {
	background-color: #f0f2f5;
}
.my_top{
	height: 350rpx;
	background: url(../../static/img/top_bg3.png) no-repeat;
	/* background: url(../../static/img/my_top.png) no-repeat; */
	background-size: 100% 100%;
	position: relative;
}
.my_top_top {
	display: flex;
	justify-content: space-between;
	display: flex;
	box-sizing: border-box;
	position: relative;
	width: 100%;
	padding: 96rpx 32rpx 0rpx;
}
.my_tx {
	width: 100%;
	height: 100%;
	border-radius: 100%;
	border:4rpx solid #ffffff;
}
.my_top_top_left {
	display: flex;
	align-items: center;
}
.my_tx_left {
	width: 110rpx;
	height: 110rpx;
	position: relative;
}
.my_top_top_name {
	margin-left: 28rpx;
}
.my_top_she{
	margin-bottom: 10rpx;
}
.my_top_top_name p:first-child {
	margin: 6rpx 0 10rpx 0;
}
.my_bottom {
	padding: 0 10rpx;
	/* margin-top: -64rpx; */
	margin-top:10rpx;
}
.my_list {
	background-color: #ffffff;
	margin-bottom: 10rpx;
	border-radius: 10rpx;
}
.my_list_top_body {
	padding: 0 24rpx;
}
.my_list_top {
	display: flex;
	justify-content: space-between;
	border-bottom: 1px solid #eeeeee;
	height: 96rpx;
	align-items: center;
}
.my_list_top image {
	width: 10rpx;
	height: 18rpx;
	margin-left: 12rpx;
}
.my_list_bottom {
	display: flex;
	flex-wrap: wrap;
	padding: 32rpx 0 0;
}
.my_item {
	text-align: center;
	font-weight: bold;
	position: relative;
}
.weidu{
	position: absolute;
	width: 30rpx;
	height: 30rpx;
	background-color: #c43c19;
	border-radius: 15rpx;
	line-height: 30rpx;
	text-align: center;
	top: -10rpx;
	right: 40rpx;
}
.my_zhanghao_bottom image{
	width: 74rpx;
	height: 74rpx;
	margin-bottom: 20rpx;
	vertical-align: bottom;
}
.my_zhanghao_bottom .my_item{
	width:20% ;
	margin-bottom: 30rpx;
}
.my_top_top_right{
	display: flex;
	align-items: center;
}
.my_top_top_right button{
	width: 150rpx;
	height: 60rpx;
	background: none;
	border-radius: 30rpx;
	border: solid 2rpx #ff2b46;
	margin-left: 20rpx;
	line-height: 60rpx;
}
.my_shujv{
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0rpx 50rpx 0rpx;
	width: 100%;
	box-sizing: border-box;
	margin: 40rpx 0 15rpx;
}
.my_shujv text{
   /* margin-left: 10rpx; */
}
.my_shujv,.my_list,.my_top_top_name,.my_list_top{
	font-family: PingFangSCBold;
}

.my_shujv_item{
	text-align: center;
}
.my_shujv_item_top{
	margin-bottom: 8rpx;
}

.shezhi{
	width: 118rpx;
	height: 50rpx;
	border-radius: 25rpx;
	border: solid 2rpx #333333;
	display: flex;
	align-items: center;
	justify-content: center;
	position: absolute;
	right: 30rpx;
	bottom: 50rpx;
}
.shezhi image{
	width: 26rpx;
	height: 24rpx;
	margin-right: 4rpx;
}
.padding10{
	padding: 0 10rpx;
}

.zhudeng{
	margin-left: 28rpx;
	display: flex;
	align-items: center;
}
.zhudeng image{
	width: 14rpx;
	height: 26rpx;
	margin-left: 14rpx;
}
.change{
	width: 200rpx;
	height: 50rpx;
	border-radius: 5rpx;
	border: solid 2rpx #6a3906;
	line-height: 50rpx;
	text-align: center;
	margin-top: 20rpx;
}
.pinpai{
	padding: 0 10rpx;
	border-radius: 45rpx;
	overflow: hidden;
	margin-bottom: 10rpx;
	/* margin-top: 20rpx; */
}
.pinpai image{
	height: 85rpx;
	width: 100%;
	vertical-align: bottom;
	
}
.hong_item .weidu{
	background-color: #e7246a;
}
.copy{
	width: 83rpx;
	height: 42rpx;
	background-color: #ffffff;
	border-radius: 22rpx;
	border: solid 1rpx #fd4c61;
	text-align: center;
	line-height: 42rpx;
	margin-left: 16rpx;
}
.tan_login{
	width: 600rpx;
	text-align: center;
	box-sizing: border-box;
}

.tan_login_tishi{
	text-align: center;
	line-height: 130rpx;
}
.tan_login_bottom{
	text-align: center;
}
.tan_login_bottom button{
	width: 467rpx;
	height: 80rpx;
	line-height: 80rpx;
	border-radius: 40rpx;
	margin: 0 auto;
	background-color: #e7246a;
}
.tan_login_logo image{
	width: 124rpx;
	height: 124rpx;
	border: 4rpx solid #ffffff;
	margin-top: -62rpx;
	border-radius: 100%;
	vertical-align: bottom;
	margin-bottom: 30rpx;
}
.tan_login_close image{
	width: 60rpx;
	height: 60rpx;
	margin-top: 60rpx;
}
.tan_login_box{
	height: 420rpx;
	background-color: #ffffff;
	border-radius: 34rpx;
}
.my_weixin{
	width: 52rpx;
	height: 52rpx;
	margin: 0 10rpx;
}

.ma_save{
	width: 280rpx;
	height: 76rpx;
	background-color: #ffffff;
	border-radius: 38rpx;
	border: solid 1rpx #fe5357;
	text-align: center;
	line-height: 76rpx;
	margin: 0 auto;
}
.tan_weixin_hao_num{
	margin: 0 10rpx 0 30rpx;
}
.tan_weixin_hao_copy{
	width: 76rpx;
	height: 40rpx;
	background-color: #ffffff;
	border-radius: 20rpx;
	border: solid 1rpx #fd4259;
	text-align: center;
	line-height: 40rpx;
}
.my_ruzhu image{
	width: 100%;
	vertical-align: bottom;
	margin-bottom: 10rpx;
}
.tan_login_mima{
	margin-top: 18rpx;
}
</style>
